import request from '@/utils/request'

// 获取设备列表
export const getEquipment = (params) => {
  return request({
    url: '/api/vm-service/vm/search',
    params
  })
}

// 获取策略下拉列表
export const getPolicy = () => {
  return request({
    url: '/api/vm-service/policy'
  })
}

// 获取当前策略情况
export const getStrategy = (id) => {
  return request({
    url: '/api/vm-service/policy/vmPolicy/' + id,
    method: 'get'
  })
}

// 取消策略
export const cancelStrategy = (innerCode, policyId) => {
  return request({
    url: '/api/vm-service/vm/cancelPolicy/' + innerCode + '/' + policyId,
    method: 'put'
  })
}

// 应用策略
export const setStrategy = (data) => {
  return request({
    url: '/api/vm-service/vm/applyPolicy',
    method: 'put',
    data
  })
}

// 新建设备
// 获取型号下拉选项
export const getModel = () => {
  return request({
    url: '/api/vm-service/vmType/search?pageIndex=1&pageSize=100000',
    method: 'get'
  })
}
// 获取点位下拉选项
export const getPoint = () => {
  return request({
    url: '/api/vm-service/node/search?pageIndex=1&pageSize=100000',
    method: 'get'
  })
}
// 确定新建
export const enterBuild = (data) => {
  return request({
    url: 'api/vm-service/vm',
    method: 'post',
    data
  })
}

// 确认修改
export const enterModify = (id, value) => {
  return request({
    url: `/api/vm-service/vm/${id}/${value}`,
    method: 'put'
  })
}

// 获取商品列表
export const getGoodsList = (innerCode) => {
  return request({
    url: `api/vm-service/channel/channelList/${innerCode}`
  })
}

// 获取设备配置
export const getEquipmentConfig = (id) => {
  return request({
    url: `api/vm-service/vmType/${id}`,
    method: 'get'
  })
}

// 获取商业圈
export const getCBD = (businessId) => {
  return request({
    url: `/api/vm-service/businessType/name/${businessId}`
  })
}
// 获取建议
export const getProposal = (businessId) => {
  return request({
    url: `api/vm-service/sku/businessTop10/${businessId}`
  })
}
// 应用排序
export const changeSrot = (data) => {
  return request({
    url: '/api/vm-service/channel/channelConfig',
    method: 'put',
    data
  })
}
// 获取添加列表
export const addGoods = (params) => {
  return request({
    url: '/api/vm-service/sku/search',
    params
  })
}
// --------------------------设备状态页--------------------------//
// 获取订单总数
export const getOrderCount = (params) => {
  return request({
    url: '/api/order-service/report/orderCount',
    params
  })
}
// 获取收入
export const getOrderAmount = (params) => {
  return request({
    url: '/api/order-service/report/orderAmount',
    params
  })
}
// 获取补货次数
export const getSupplyCount = (innerCode, start, end) => {
  return request({
    url: `/api/task-service/task/supplyCount/${innerCode}/${start}/${end}`
  })
}
// 获取维修次数
export const getRepairCount = (innerCode, start, end) => {
  return request({
    url: `/api/task-service/task/repairCount/${innerCode}/${start}/${end}`
  })
}
// 获取商品销量
export const getSkuCollect = (innerCode, start, end) => {
  return request({
    url: `/api/order-service/report/skuCollect/${innerCode}/${start}/${end}`
  })
}

// --------------------------设备类型管理页--------------------------//
// 获取设备类型
export const getVmModel = (params) => {
  return request({
    url: '/api/vm-service/vmType/search',
    params
  })
}
// 删除设备类型
export const delVmModel = (typeId) => {
  return request({
    url: `/api/vm-service/vmType/${typeId}`,
    method: 'delete'
  })
}

// 新增设备类型
export const addVmModel = (data) => {
  return request({
    url: 'api/vm-service/vmType',
    method: 'post',
    data
  })
}
// 修改设备类型
export const editVmModel = (data, typeId) => {
  return request({
    url: `api/vm-service/vmType/${typeId}`,
    method: 'put',
    data
  })
}
